﻿using HandyControl.Tools.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace EasyFlow
{
    /// <summary>
    /// VariableSelector.xaml 的交互逻辑
    /// </summary>
    public partial class VariableSelector : UserControl
    {
        public string VariableExpressionName
        {
            get { return (string)GetValue(VariableExpressionNameProperty); }
            set { SetValue(VariableExpressionNameProperty, value); }
        }
        public static readonly DependencyProperty VariableExpressionNameProperty =
            DependencyProperty.Register("VariableExpressionName", typeof(string), typeof(VariableSelector), new PropertyMetadata(""));
        public ICommand VariableLinkButtonClickCommand
        {
            get { return (ICommand)GetValue(VariableLinkButtonClickCommandProperty); }
            set { SetValue(VariableLinkButtonClickCommandProperty, value); }
        }
        public static readonly DependencyProperty VariableLinkButtonClickCommandProperty =
            DependencyProperty.Register("VariableLinkButtonClickCommand", typeof(ICommand), typeof(VariableSelector), new PropertyMetadata(null));
        public ICommand VariableExpButtonClickCommand
        {
            get { return (ICommand)GetValue(VariableExpButtonClickCommandProperty); }
            set { SetValue(VariableExpButtonClickCommandProperty, value); }
        }
        public static readonly DependencyProperty VariableExpButtonClickCommandProperty =
            DependencyProperty.Register("VariableExpButtonClickCommand", typeof(ICommand), typeof(VariableSelector), new PropertyMetadata(null));
        public string VariableExp
        {
            get { return (string)GetValue(VariableExpProperty); }
            set { SetValue(VariableExpProperty, value); }
        }
        public static readonly DependencyProperty VariableExpProperty =
            DependencyProperty.Register("VariableExp", typeof(string), typeof(VariableSelector), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));

        public VariableSelector()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((sender as Button)?.Name.Equals("LinkButton") == true)
                VariableLinkButtonClickCommand?.Execute(null);
            else if ((sender as Button)?.Name.Equals("ExpButton") == true)
                VariableExpButtonClickCommand?.Execute(null);
        }
    }
}
